package me.boot.db.jpa.template.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import me.base.commom.Identifiable;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author :  sylar
 * @FileName :  AbstractJpaEntityWithAutoId
 * @CreateDate :  2017/11/08
 * @Description :
 * @ReviewedBy :
 * @ReviewedOn :
 * @VersionHistory :
 * @ModifiedBy :
 * @ModifiedDate :
 * @Comments :
 * @CopyRight : COPYRIGHT(c) xxx.com All Rights Reserved
 * *******************************************************************************************
 */
@Getter
@Setter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class Entity implements Identifiable<Long> {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Long id;

    protected String name;

    @JsonIgnore
    @CreatedBy
    @Column(updatable = false)
    protected String createBy;
    @JsonIgnore
    @CreatedDate
    @Column(updatable = false)
    protected Date createdDate;
    @JsonIgnore
    @LastModifiedBy
    protected String lastModifiedBy;
    @JsonIgnore
    @LastModifiedDate
    protected Date lastModifiedDate;
    @JsonIgnore
    @Column(name = "deleted")
    protected boolean deleted = false;

    protected boolean enabled = true;
    protected String properties;
    protected String description;

}
